package com.bw.user.mvvm.viewmodel;

import androidx.databinding.ObservableField;

import com.blankj.utilcode.util.ToastUtils;
import com.bw.mvvm_comom.entity.BaseEntity;
import com.bw.mvvm_comom.filed.UIFiled;
import com.bw.mvvm_comom.mvvm.BaseViewModel;
import com.bw.user.mvvm.model.ForgetPwdModel;
import com.bw.user.mvvm.view.activity.ResetActivity;

import java.util.HashMap;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class ForgetPwdViewModel extends BaseViewModel<ForgetPwdModel> {
    public ObservableField<String> phone = new ObservableField<>();
    public ObservableField<String> verify = new ObservableField<>();
    public ObservableField<String> timeStr = new ObservableField<>("获取验证码");


    @Override
    public void onCreate() {
        super.onCreate();

    }

    public void next(){
        if (phone.get().isEmpty()){
            ToastUtils.showShort("请输入手机号");
            return;
        }
        if (verify.get().isEmpty()){
            ToastUtils.showShort("请输入密码");
            return;
        }
        HashMap<String,Object> map = new HashMap<>();
        map.put("mobile",phone.get());
        map.put("verifyCode",verify.get());
        m.requestForgetPwdModel(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
        HashMap<String,Object> clazzMap = new HashMap<>();
        map.put(UIFiled.PAGECLAZZ, ResetActivity.class);
        getUiChange().getStartPageObServAble().setValue(map);

    }


    @Override
    protected void result(BaseEntity baseEntity) {

//        if (baseEntity.getMessage().equals("验证成功")){
//        }
    }

    public void verify(){

    }
    public void finish(){
        getUiChange().getFinishActObServAble().setValue(""+System.currentTimeMillis());
    }
}
